package com.douples.citywide.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.douples.citywide.R;
import com.squareup.picasso.Picasso;

/**
 * Created by liuwei on 2017/7/7.
 */

public class MyFragment extends Fragment {

    private ImageView imageView;
    private Context context;

    public static MyFragment getInstance(String url) {
        Bundle bundle = new Bundle();
        bundle.putString("url", url);
        MyFragment myFragment = new MyFragment();
        myFragment.setArguments(bundle);
        return myFragment;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.context = context;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fg_my_layout, container,false);
        imageView=view.findViewById(R.id.iv);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        String url = getArguments().getString("url");
        Picasso.with(context).load(url).into(imageView);
    }
}
